Skip to content

Add numba dispatch for SVD#2136

Merged
jessegrabowski merged 3 commits into
pymc-devs:mainfrom
jessegrabowski:numba-svd
May 20, 2026
Merged

Add numba dispatch for SVD#2136
jessegrabowski merged 3 commits into
pymc-devs:mainfrom
jessegrabowski:numba-svd

Conversation

@jessegrabowski
Copy link
Copy Markdown
Member

Fun fact, there are no decompositions left for me to implement when i'm bored.

@jessegrabowski jessegrabowski requested a review from ricardoV94 May 15, 2026 03:58
@ricardoV94
Copy link
Copy Markdown
Member

ricardoV94 commented May 15, 2026

Fun fact, there are no decompositions left for me to implement when i'm bored

What about https://en.wikipedia.org/wiki/CUR_matrix_approximation

https://en.wikipedia.org/wiki/Interpolative_decomposition

https://en.wikipedia.org/wiki/Polar_decomposition

https://en.wikipedia.org/wiki/Category:Matrix_decompositions

Comment thread pytensor/link/numba/dispatch/linalg/decomposition/dispatch.py Outdated
if discrete_input:
x = x.astype(out_dtype)
return np.linalg.svd(x, full_matrices)
return _svd_gesdd_full(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

worth a (one time) bench we are doing better than the numba dispatch?

op = svd.SVD(
full_matrices=full_matrices,
compute_uv=compute_uv,
overwrite_a=overwrite_a,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest using the actual inplace path with requires starting with a regular Blockwise and just seeing the root input as mutable. Then check the destroy map of the compiled function?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so not starting with inplace graph

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed a commit with this, check if you're happy

@jessegrabowski
Copy link
Copy Markdown
Member Author

What about https://en.wikipedia.org/wiki/CUR_matrix_approximation

There's also https://en.wikipedia.org/wiki/Cholesky_decomposition#LDL_decomposition

You are right though, I have a long and fruitful career of implementing matrix decompositions that nobody asked for still stretching out ahead of me. Bullet dodged!

@ricardoV94
Copy link
Copy Markdown
Member

Did I break mypy?

@jessegrabowski
Copy link
Copy Markdown
Member Author

maybe just a new failure due to the settings? Looks like its firing fine, i can just fix it here.

@ricardoV94
Copy link
Copy Markdown
Member

maybe just a new failure due to the settings? Looks like its firing fine, i can just fix it here.

thanks

@jessegrabowski jessegrabowski merged commit ea93e49 into pymc-devs:main May 20, 2026
66 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants